package cn.cdutetc.library.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 支付类型枚举
 */
@Getter
@AllArgsConstructor
public enum PaymentTypeEnum {

    FINE(1, "罚款"),
    LOST_COMPENSATION(2, "丢失赔偿"),
    MEMBERSHIP_FEE(3, "会员费"),
    OTHER(4, "其他");

    private final Integer code;
    private final String desc;

    /**
     * 根据code获取枚举
     * @param code 状态码
     * @return 枚举
     */
    public static PaymentTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PaymentTypeEnum type : PaymentTypeEnum.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
}